package model

import (
	"fmt"
	"gorm.io/gorm"
	"tem/global"
)

// Like 点赞table模型
type Like struct {
	UserId    uint `json:"userId" gorm:"column:user_id"`        //点赞用户
	InstantId uint `json:"instant_id" gorm:"column:instant_id"` //点赞瞬间的id
}

func (Like) TableName() string {
	return "likeTable"
}

func (Like) Create(l Like) *gorm.DB {
	tx := global.DB.Create(&l)
	return tx
}

func (Like) Delete(l Like) error {
	fmt.Printf("%#v", l)
	return global.DB.Where("user_id = ? and instant_id = ?", l.UserId, l.InstantId).Delete(&Like{}).Error
}
